
<template>
  <el-dialog  :modelValue="dialogVisible"  title="控制开出属性"  width="60%"
              :close-on-click-modal="false"
              :close-on-press-escape="false"
  >
    <el-form :model="formData" label-width="120px"   >
      <el-form-item label="项目" >
        <el-select v-model="formData.projectId" placeholder="请选择项目">
          <el-option
            v-for="item in projects"
            :key="item.id"
            :label="item.descr"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="开出编号" >
        <el-input  v-model="formData.ctlid"  style="width: 80%"></el-input>
      </el-form-item>
      <el-form-item label="描述" >
        <el-input  v-model="formData.descr"  style="width: 80%"></el-input>
      </el-form-item>
      <el-form-item label="开出位置" >
        <el-input  v-model="formData.ctlkey"  style="width: 80%"></el-input>
      </el-form-item>
      <el-form-item label="开出串" >
        <el-input  v-model="formData.ctlstr"  style="width: 80%"></el-input>
      </el-form-item>
      <el-form-item label="备注" >
        <el-input  v-model="formData.memo"  style="width: 80%"></el-input>
      </el-form-item>

    </el-form>

    <template #footer>
      <span class="dialog-footer">
            <el-button type="primary" @click="handleOk">确定</el-button>
            <el-button type="primary" @click="handleCancel">取消</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>

import { mapState } from 'vuex'

export default {
  name: "DlgPropCtlCmd",
  components: {  },
  props:{ dialogVisible: Boolean, formData: Object },
  emits:["resPropCtlCmd"],

    computed: {
        ...mapState(['project_id']),
        ...mapState(['projects']),

        selectedProjectLabel() {
          if (!this.formData.projectId) return '';
          const selectedItem = this.projects.find(item => item.id === this.formData.projectId);
          return selectedItem ? selectedItem.descr : '';
        }
  },  


  mounted(){
  },

  watch: {

  },

  data(  ){
    return{

    }
  },

  methods:{
      handleOk(  ){
        this.formData.projectname = this.selectedProjectLabel
        this.$emit("resPropCtlCmd", 1, this.formData );
      },

      handleCancel(  ){
        this.$emit("resPropCtlCmd", 0, this.formData );
      },

  },
}

</script>

<style lang="less" scoped>

</style>